package com.tiny.tinyweb.core.test;

import org.junit.runner.RunWith;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;
import org.springframework.test.context.transaction.TransactionConfiguration;
import org.springframework.transaction.annotation.Transactional;

/**
 * DAO对象单元测试的基类，该类使用
 * {@link org.springframework.test.context.junit4.SpringJUnit4ClassRunner}
 * 来执行，并通过{@link UnitTestDaoExecutionListener}管理dbunit的数据集。
 * 每个测试方法都在一个事务中执行，测试方法执行完毕会回滚数据。
 *
 * @see {@link UnitTestDaoExecutionListener}
 * @author wxiaobin
 */
@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({DependencyInjectionTestExecutionListener.class,
        DirtiesContextTestExecutionListener.class, UnitTestDaoExecutionListener.class})
@Transactional
@TransactionConfiguration(transactionManager = "transactionManager", defaultRollback = true)
public abstract class UnitTestDao extends UnitTest {
}
